package switchviz.graphic.signal;

import javax.swing.JPanel;

import org.jdom.Element;

import switchviz.core.signal.Signal;

public class UpSignal extends Signal implements IGaugeSignal {

	private int counter = Integer.MAX_VALUE;
	
	private static final int FPS = 30;
	private static final int SAMPLETIME = 1000;
	
	private float rate = FPS * (((float) SAMPLETIME)/1000f);
	
	private float _on = 1.0f;
	
	public UpSignal(int port)
	{
		setAliasName("ifOperStatus");
		setPort(port);
	}

	public int getAlarmmode() 
	{
		return 0;
	}

	public float[] getColor() 
	{
		return null;
	}

	public Element getElement() 
	{
		return null;
	}

	public float getMax() 
	{
		return 0;
	}

	public float getMin() 
	{
		return 0;
	}

	public String getName() 
	{
		return "UpSignal";
	}

	public JPanel getPanel() 
	{
		return null;
	}

	public int getPriority() 
	{
		return 100;
	}

	public String getType() 
	{
		return "UpSignal";
	}

	public float getValue() 
	{
		
		if (getData() != null)
		{		
			if (counter > rate)
			{
				if(getData().getValue() != null)
				{
					if(getData().getValue().getClass().equals(Integer.class))
					{
						_on = (Integer)(getData().getValue());
					}
					else if(getData().getValue().getClass().equals(Long.class))
					{
						_on = (Long)(getData().getValue());
					}
				}
				counter = 0;
			}	
			counter++;
		}

		return _on;
	}

	public boolean isEnable() 
	{
		return false;
	}

	public boolean isLogarithmic() 
	{
		return false;
	}

}
